package com.lepu.app.fun.chat.core;



import android.text.TextUtils;

import org.jivesoftware.smack.packet.PacketExtension;

/**
 * Created by Chang on 12/22/2014.
 */
public class ServerReceiptExtension implements PacketExtension {

    public static final String NAMESPACE = "urn:lepu:server:receipts";
    public static final String NAMESPACE_CLIENT = "'urn:lepu:client:receipts'";
    public static final String ELEMENT_NAME = "received-extension";

    private String elementName = "";
    private String namespace = "";

    private String messageId = "";
    private String content = "";
    private String chatType = "";

//    public ServerReceiptExtension() {
//        this.elementName = ELEMENT_NAME;
//        this.namespace = NAMESPACE;
//    }

    public ServerReceiptExtension(String elementName,String namespace) {
        this.elementName = elementName;
        this.namespace = namespace;
    }

    @Override
    public String getElementName() {
        return ELEMENT_NAME;
    }

    @Override
    public String getNamespace() {
        return NAMESPACE;
    }


    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public CharSequence toXML() {
        StringBuffer buf = new StringBuffer();
        buf.append("<").append(elementName);
        buf.append(" xmlns=").append(namespace).append(">");
        buf.append("<origin-id>").append(getMessageId()).append("</origin-id>");

        if(!TextUtils.isEmpty(getContent()))
        {
            buf.append("<type>").append(getContent()).append("</type>");
        }

        if(!TextUtils.isEmpty(getChatType()))
        {
            buf.append("<chat-type>").append(getChatType()).append("</chat-type>");
        }

        buf.append("</").append(elementName).append(">");

        return buf.toString();
    }

    public String getChatType() {
        return chatType;
    }

    public void setChatType(String chatType) {
        this.chatType = chatType;
    }

//    public static class Provider extends org.jivesoftware.smack.provider.EmbeddedExtensionProvider {
//        public Provider() { /* compiled code */ }
//
//        protected org.jivesoftware.smack.packet.PacketExtension createReturnExtension(java.lang.String s, java.lang.String s1, java.util.Map<java.lang.String,java.lang.String> map, java.util.List<? extends org.jivesoftware.smack.packet.PacketExtension> list) { /* compiled code */ }
//    }


}
